import Vue from 'vue'
import App from './App.vue'
import store from './store'
import router from './router'
import axios from 'axios'
import VueAxios from 'vue-axios'
import infiniteScroll from 'vue-infinite-scroll'
// import './assets/css/base.css'
// import './assets/css/checkout.css'
// import './assets/css/login.css'
// import './assets/css/product.css'
import '@/assets/css/base.css'
import '@/assets/css/checkout.css'
import '@/assets/css/login.css'
import '@/assets/css/product.css'

// let loading = null
// let requestCount = 0
// // 显示loading
// function showLoading(){
//   if(requestCount === 0){
//     loading = Message({
//       message: '加载中...',
//       duration:0
//     });
//   }
//   requestCount++
// }
// // 隐藏loading
// function hideLoading(){
//   if(requestCount > 0){
//     requestCount--
//   }
//   if(loading && requestCount === 0){
//     loading.close()
//   }
// }

// 添加请求拦截器
axios.interceptors.request.use((config)=>{

  console.log('请求拦截器 成功');
  config.headers['authorization'] = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiaWF0IjoxNTk1MzM5MTczfQ.vEUCG_pmsJbl-LwrxE8pCT7HhlbGzdMCffbk2dZF0Mo";

  return config;
}, (error)=> {
  // 隐藏loading
  // hideLoading()
  // 对请求错误做些什么
  return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use((response)=>{
  console.log('响应拦截器 成功');

  return response.data;
},(err)=> {
  // 全局错误提示

  return Promise.reject(err);
});

Vue.use(VueAxios,axios);
Vue.use(infiniteScroll);
Vue.config.productionTip = false;
new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app');
